﻿using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AvaloniaMVVMSample.Models;

public class FolderModel : SystemModel
{
    public string Name { get; set; }
    public string Path { get; set; }
    public string Size { get; set; } = "";
    public string Extension { get; set; } = "";

    public FolderModel(FileSystemInfo file)
    {
        Name = file.Name;
        Path = file.FullName;
    }

    public FolderModel(string path)
    {
        var info = new DirectoryInfo(path);
        Path = path;
        Name = info.Name;
    }

    public List<SystemModel> GetChildren()
    {
        var info = new DirectoryInfo(Path);
        return info.GetFileSystemInfos().Where(x =>
            (x.Attributes & FileAttributes.System) != FileAttributes.System &&
            (x.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden).Select(x => x.GetSys()).ToList();
    }
}